ABC007 C - 幅優先探索
提出
code: python
from collections import deque
r, c = map(int, input().split())
sy, sx = map(int, input().split())
gy, gx = map(int, input().split())
que = deque(sy-1, sx-1, 1)
dis = 1
while (len(que) != 0):
nowY, nowX, dis = que.popleft()
if (nowX < 0 or nowX > c or nowY < 0 or nowY > r or mazenowYnowX == "#" or visitednowYnowX != 0): continue
else:
dis += 1
テーマ
メモ
code: python
from collections import deque
r, c = map(int, input().split())
si, sj = map(int, input().split())
gi, gj = map(int, input().split())
que = deque(si-1, sj-1)
while que:
nowi, nowj = que.popleft()
nexti, nextj = nowi + i, nowj + j
if (nexti < 0 or nexti > r or nextj < 0 or nextj > c or areanextinextj == "#" or disnextinextj != 0): continue
else: